﻿@model EnterpriseFund.Model.TaxItem
@{
    Layout = null;
}
<!DOCTYPE html>
<html>
@Html.Partial("LoadPanelPartial")
<head>
    <title></title>
    @if (false)
    {
        <script src="../../Scripts/jquery-vsdoc.js" type="text/javascript"></script>
        <script src="../../Scripts/ASPxScriptIntelliSense.js" type="text/javascript"></script>
    }
    <link href="@Url.Content("~/Content/Site.css", true)" rel="stylesheet" type="text/css" />

    <script src="@Url.Content("~/Scripts/jquery.min.js", true)" type="text/javascript"></script>
    <script src="@Url.Content("~/Common/GetRootPath.ashx", true)" type="text/javascript"></script>

    @Html.DevExpress().GetStyleSheets(

        new StyleSheet { ExtensionType = ExtensionType.ListBox, Theme = DevExpressHelper.Theme }
)
    @Html.DevExpress().GetScripts(
        new Script { ExtensionType = ExtensionType.ListBox }
)


    <script type="text/javascript">
        function OK() {

            lpModal.Show();
            var codeNo = tbCodeNo.GetText();
            var codeName = tbCodeName.GetText();
            var FTaxClassNo = tbFTaxClassNo.GetValue();
            var FNationalTaxClassName = tbFNationalTaxItemName.GetText();
            var FIsUse = "";
            if (tbFIsUse.GetChecked()) {
                FIsUse = "Y";
            }
            else {
                FIsUse = "N";
            }

            if (pd(codeNo, codeName)) {
                codeNo = ASPxClientUtils.Trim(codeNo);
                codeName = ASPxClientUtils.Trim(codeName);
                $.ajax({
                    type: 'POST',
                    url: rootPath + '/TaxItemManager/TaxItemSave',
                    data: { taxItemNo: codeNo, taxItemName: codeName, taxClassNo: FTaxClassNo, nationalTaxItemName: FNationalTaxClassName, isUse: FIsUse, isAdd: '@ViewData["blcodeNo"]' },
                    success: function (result) {
                        lpModal.Hide();
                        if (result == "exists") {
                            tbCodeNo.SetErrorText("编码已存在");
                            tbCodeNo.SetIsValid(false);
                        } else if (result == "ok") {
                            parent.codeOK();
                        } else if (result == "error") {
                            alert("保存失败");
                        }
                    }
                });

            } else {
                lpModal.Hide();
            }

        }


        function pd(codeNo, codeName) {
            var bl = true;
            if (null == codeNo || ASPxClientUtils.Trim(codeNo) == "") {
                tbCodeNo.SetErrorText("请填写税目编号");
                tbCodeNo.SetIsValid(false);
                bl = false;
            }
            if (null == codeName || ASPxClientUtils.Trim(codeName) == "") {
                tbCodeName.SetErrorText("请填写税目名称");
                tbCodeName.SetIsValid(false);
                bl = false;
            }

            return bl;
        }

    </script>

</head>
<body>
    <table class="tableFrom">
        <tr>
            <th style=" width:150">
               税目编号:</th>
            <td>
                @Html.DevExpress().TextBox(settings =>
               {
                   settings.Name = "tbCodeNo";
                   settings.Width = 150;
                   if ((bool)@ViewData["blcodeNo"])
                   {
                       settings.ReadOnly = false;
                   }
                   else
                   {
                         settings.ReadOnly = true;
                   }
                   settings.Text = Model.FTaxItemNo;
                   settings.Properties.ValidationSettings.ErrorDisplayMode = ErrorDisplayMode.ImageWithText;
                   settings.Properties.ValidationSettings.EnableCustomValidation = true;
               }).GetHtml()
            </td>
        </tr>
        <tr>
            <th style=" width:150">
                税目名称:</th>
            <td>
                @Html.DevExpress().TextBox(settings =>
               {
                   settings.Name = "tbCodeName";
                   settings.Width = 150;
                   settings.Text = Model.FTaxItemName;
                   settings.Properties.ValidationSettings.ErrorDisplayMode = ErrorDisplayMode.ImageWithText;
                   settings.Properties.ValidationSettings.EnableCustomValidation = true;
               }).GetHtml()
            </td>
        </tr>
          <tr>
            <th style=" width:150">
                税种:</th>
            <td>
                @Html.DevExpress().ComboBox(settings =>
               {
                   settings.Name = "tbFTaxClassNo";
                   settings.Width = 150;
                   settings.Properties.DropDownStyle = DropDownStyle.DropDownList;
                   settings.Properties.TextField = "FTaxClassName";
                   settings.Properties.ValueField = "FTaxClassNo";
                   if ((bool)@ViewData["blcodeNo"])
                   {
                       settings.ReadOnly = false;
                   }
                   else
                   {
                       settings.ReadOnly = true;
                   }
                   settings.Properties.ValidationSettings.ErrorDisplayMode = ErrorDisplayMode.ImageWithText;
                   settings.Properties.ValidationSettings.EnableCustomValidation = true;
               }).BindList(ViewData["TaxClassList"]).Bind(Model.FTaxClassNo).GetHtml()
            </td>
        </tr>
          <tr>
            <th style=" width:150">
                国税对应名称:</th>
            <td>
                @Html.DevExpress().TextBox(settings =>
               {
                   settings.Name = "tbFNationalTaxItemName";
                   settings.Width = 150;
                   settings.Text = Model.FNationalTaxItemName;
                   settings.Properties.ValidationSettings.ErrorDisplayMode = ErrorDisplayMode.ImageWithText;
                   settings.Properties.ValidationSettings.EnableCustomValidation = true;
               }).GetHtml()
            </td>
        </tr>

           <tr>
            <th style=" width:150">
                有效:</th>
            <td>
                @Html.DevExpress().CheckBox(settings =>
               {
                   settings.Name = "tbFIsUse";
                   settings.Width = 150;
                   if (Model.FIsUse == "Y")
                   {
                       settings.Checked = true; 
                   }
                   settings.Properties.ValidationSettings.ErrorDisplayMode = ErrorDisplayMode.ImageWithText;
                   settings.Properties.ValidationSettings.EnableCustomValidation = true;
               }).GetHtml()
            </td>
        </tr>
       
       @* <tr>
            <td colspan="2">
                @Html.DevExpress().Button(settings =>
              {
                  settings.Name = "btnOK";
                  settings.Text = "确定";
                  settings.ControlStyle.CssClass = "left";
                  settings.ClientSideEvents.Click = "OK";
              }).GetHtml()
                @Html.DevExpress().Button(settings =>
              {
                  settings.Name = "btnCancel";
                  settings.Text = "取消";
                  settings.CausesValidation = false;
                  settings.ControlStyle.CssClass = "left";
                  settings.ClientSideEvents.Click = "function(){parent.codeCancel();}";
              }).GetHtml()
            </td>
        </tr>*@
    </table>

    <script>
        lp.Hide();
    </script>

</body>
</html>
